package com.campus_information_portal.dao;

import com.campus_information_portal.entity.Notice;
import com.campus_information_portal.entity.NoticeTeacher;
import org.apache.ibatis.annotations.*;

import java.util.Date;
import java.util.List;

/**
 * 公告管理dao层
 *
 * @author
 * @create 2018-05-13 16:48
 **/
public interface NoticeDao {

    /**
     * @param
     * @Description 查询全部公告
     * @author 20155870 杨润增
     * @methodName queryAllNotice
     * @returnType
     * @create 2018/5/13 16:51
     **/
    @Select("select notice.* ,teacher.te_name from notice,teacher where notice.te_info_id=teacher.te_info_id")
    List<NoticeTeacher> queryAllNotice();


    /**
     * @Description 增加一个公告
     * @author 20155870 杨润增
     * @methodName addNotice
     * @param
     * @returnType int
     * @create 2018/5/13 16:56
     **/
    @Insert("insert into notice(notice_id,te_info_id,notice_title,notice_content,notice_author,notice_datetime)" +
            "values(NULL,#{teInfoId},#{noticeTitle},#{noticeContent},#{noticeAuthor},#{noticeDatetime})")
    int addNotice(Notice notice);


    /**
     * @Description 更新一条公告
     * @author 20155870 杨润增
     * @methodName updateNotice
     * @param noticeTitle,noticeContent,noticeId
     * @returnType int
     * @create 2018/5/13 21:41
     **/
    @Update("update notice " +
            "set notice_content=#{noticeContent} ," +
            "notice_title=#{noticeTitle} " +
            " WHERE notice_id=#{noticeId}")
    int updateNotice(@Param("noticeId")int noticeId,
                     @Param("noticeTitle")String noticeTitle,
                     @Param("noticeContent")String noticeContent
                     );


    /**
     * @Description 删除一个公告
     * @author 20155870 杨润增
     * @methodName deleteNotice
     * @param noticeId
     * @returnType int
     * @create 2018/5/13 21:43
     **/
    @Delete("delete from notice where notice_id=#{noticeId}")
    int deleteNotice(@Param("noticeId")int noticeId);

    /**
     * @Description 根据noticeId查询一条notice
     * @author 20155870 杨润增
     * @methodName queryNoticeById
     * @param noticeId
     * @returnType NoticeTeacher
     * @create 2018/5/23 16:30
     **/
    @Select("select notice.* ,teacher.te_name from notice,teacher where notice.te_info_id=teacher.te_info_id and notice_id=#{noticeId}")
    NoticeTeacher queryNoticeById(@Param("noticeId")int noticeId);
}
